---
title: "Reference: Agent.getModel() | Agents"
description: "Documentation for the `Agent.getModel()` method in Mastra agents, which retrieves the language model that powers the agent."
---

# Agent.getModel()

The `.getModel()` method retrieves the language model configured for an agent, resolving it if it's a function. This method is used to access the underlying model that powers the agent's capabilities.

## Usage example

```typescript copy
await agent.getModel();
```

## Parameters

<PropertiesTable
  content={[
    {
      name: "{ requestContext = new RequestContext() }",
      type: "{ requestContext?: RequestContext }",
      isOptional: true,
      defaultValue: "new RequestContext()",
      description: "Optional configuration object containing request context.",
    },
  ]}
/>

## Returns

<PropertiesTable
  content={[
    {
      name: "model",
      type: "MastraLanguageModel | Promise<MastraLanguageModel>",
      description:
        "The language model configured for the agent, either as a direct instance or a promise that resolves to the model.",
    },
  ]}
/>

## Extended usage example

```typescript copy
await agent.getModel({
  requestContext: new RequestContext(),
});
```

### Options parameters

<PropertiesTable
  content={[
    {
      name: "requestContext",
      type: "RequestContext",
      isOptional: true,
      defaultValue: "undefined",
      description:
        "Request Context for dependency injection and contextual information.",
    },
  ]}
/>

## Related

- [Agents overview](/docs/v1/agents/overview)
- [Request Context](/docs/v1/server-db/request-context)
